import { useEffect } from "react";
import { useRouteProps } from "umi";

interface IRouteCustomProps {
  id: string;
  parentId: string;
  path: string;
  meta?: { title: string };
}

/**
 * @description 自动更新窗口title
 */
function useTitle() {
  const routeProps = useRouteProps<IRouteCustomProps>();
  useEffect(() => {
    const { meta } = routeProps;
    document.title = meta?.title || "生产性项目实训3";
  }, [routeProps]);
}

export default useTitle;
